<template>
	<view class="lh-container">
		<img-top :imgSrc="'/static/lh/tg/car.png'"></img-top>
		
		<view class="login-btn" style="text-align: center">
			<image src="/static/lh/tg/btn.png" mode="widthFix" style="width: 600rpx" @click="submitform"></image>
		</view>
		<view class="fixed-phone" @click="phone">
			<image src="/static/lh/phone.png" style="width: 60rpx" mode="widthFix"></image>
		</view>
		<view class="fixed-active" @click="privatePro(2524)">
			<image src="/static/lh/rule.png" style="width: 60rpx" mode="widthFix"></image>
		</view>
		<view class="fixed-link" @click="goLink">
			<image src="/static/lh/link.png" style="width: 60rpx" mode="widthFix"></image>
		</view>
		<uni-popup ref="popupOk" type="bottom" border-radius="10px 10px 0 0">
			<per-info :agreementType="agreeType" @ok="ok1"></per-info>
		</uni-popup>
	</view>
</template>

<script setup>
import { ref, reactive, onMounted, watchEffect, watch } from 'vue';
import { onLoad, onPageScroll, onReady } from '@dcloudio/uni-app';
import perInfoVue from '@/components/per-info/per-info.vue';
import { storeToRefs } from 'pinia';
import { useEquityStore } from '@/store/equity';
import initApi from '@/apis/init.js';
const {userInfo} = storeToRefs(useEquityStore())
const popupOk = ref();
const agreeType = ref(1);
onLoad(() => {
	userLogin();
});
const userLogin = () => {
	uni.login({
		provider: 'weixin',
		success: (res) => {
			console.log(res,'---》》');
			const jsCode = res.code
			initApi.userLogin({
				appId:"wx5c9c265e473a0aef",
				code:res.code
			}).then(res=>{
				console.log(res);
			}).catch(e=>{
				console.log(e,'报错');
			})
			// 走后端
			// uni.request({
			// 	url: 'https://api.weixin.qq.com/sns/jscode2session', // 请求微信服务器
			// 	method: 'GET',
			// 	data: {
			// 		appid: 'wxa1ecc66bef131642', //你的小程序的APPID
			// 		secret: 'ef81909ac0f98fb0bd1062f7c099481a', //你的小程序秘钥secret,
			// 		js_code: res.code, //uni.login 登录成功后的code
			// 		grant_type: 'authorization_code' //此处为固定值
			// 	},
			// 	success: (res) => {
			// 		console.log('获取信息', res.data);
			// 		// this.session_key = res.data.session_key;
			// 	}
			// });
		}
	});
};
const submitform = () => {
	// userLogin()
};
const phone = () => {
	uni.makePhoneCall({
		phoneNumber: '400-8825010' //客服
	});
};
const ok1 = () => {
	popupOk.value.close();
	// allChecked.value = true;
};
const goLink=()=>{
	userInfo.value.pageName = '停车券'
	uni.navigateTo({
		url:'/pages/lhhy/equity'
	})
}
const privatePro = (type) => {
	agreeType.value = type
	popupOk.value.open('center');
};
</script>

<style lang="scss" scoped>
.lh-container {
	width: 750rpx;
	margin: 0 auto;
	height: 100%;
	// background-color: #3d4ca6;
	background: linear-gradient(to right, #3d4ca6, #2e3a8b);
	box-sizing: border-box;
	overflow-x: hidden;
}

.fixed-phone {
	position: absolute;
	top: 300rpx;
	right: 0rpx;
}
.fixed-active {
	position: absolute;
	top: 150rpx;
	right: 0rpx;
}
.fixed-link {
	position: absolute;
	top: 450rpx;
	right: 0rpx;
}
</style>
